package com.fingard.constant;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

public class Format {
    /**
     * yyyy-MM-dd HH:mm
     */
    public static final DateFormat2 DateTimeMinFormat = new DateFormat2("yyyy-MM-dd HH:mm");

    /**
     * yyyy-MM-dd HH:mm:ss
     */
    public static final DateFormat2 DateTimeFormat = new DateFormat2("yyyy-MM-dd HH:mm:ss");

    public static final DateFormat2 DateTime1Format = new DateFormat2("yyyy-MM-ddHH:mm:ss");
    /*yyyy-MM-ddTHH:mm:ss*/
    public static final DateFormat2 DateTime2Format = new DateFormat2("yyyy-MM-dd'T'HH:mm:ss");

    /**
     * yyMMddHHmmss
     */
    public static final DateFormat2 DateTime12Year2Format = new DateFormat2("yyMMddHHmmss");

    /**
     * yyyyMMddHHmmss
     */
    public static final DateFormat2 DateTime14Format = new DateFormat2("yyyyMMddHHmmss");

    /**
     * ddMMyyyyHHmmss
     */
    public static final DateFormat2 DateTime14Format2 = new DateFormat2("ddMMyyyyHHmmss");
    /**
     * yyyyMMdd HH:mm:ss
     */
    public static final DateFormat2 DateTime14Format3 = new DateFormat2("yyyyMMdd HH:mm:ss");

    /**
     * yyyyMMddHHmmssSSS
     */
    public static final DateFormat2 DateTime17Format = new DateFormat2("yyyyMMddHHmmssSSS");

    /**
     * yyMMddHHmmssSSS
     */
    public static final DateFormat2 DateTime15Year2Format = new DateFormat2("yyMMddHHmmssSSS");

    /**
     * yyyyMMddHHmmssSSS
     */
    public static final DateFormat2 DateTime16Format = new DateFormat2("yyyy-MM-ddHHmmss");

    /**
     * yyyy-MM-dd HH:mm:ss.SSS
     */
    public static final DateFormat2 DateTime23Format = new DateFormat2("yyyy-MM-dd HH:mm:ss.SSS");

    /**
     * yyyy-MM-dd HH:mm:ss.SS
     */
    public static final DateFormat2 DateTime22Format = new DateFormat2("yyyy-MM-dd HH:mm:ss.SS");

    /**
     * yyyy-MM-dd HH:mm:ss.S
     */
    public static final DateFormat2 DateTime21Format = new DateFormat2("yyyy-MM-dd HH:mm:ss.S");

    /**
     * yyyy-MM-dd HH:mm:ss SSS
     */
    public static final DateFormat2 DateTimeSSSFormat = new DateFormat2("yyyy-MM-dd HH:mm:ss SSS");

    /**
     * yyyyMMddHHmmssSSS
     */
    public static final DateFormat2 DateTime17SSSFormat = new DateFormat2("yyyyMMddHHmmssSSS");

    /**
     * yyyyMMdd
     */
    public static final DateFormat2 Date8Format = new DateFormat2("yyyyMMdd");

    /**
     * yyMMdd
     */
    public static final DateFormat2 Date6Format = new DateFormat2("yyMMdd");

    /**
     * yyyy-MM-dd
     */
    public static final DateFormat2 Date10Format = new DateFormat2("yyyy-MM-dd");

    /**
     * yyyy/MM/dd
     */
    public static final DateFormat2 Date10Format2 = new DateFormat2("yyyy/MM/dd");

    /**
     * dd/MM/yyyy
     */
    public static final DateFormat2 Date10Format3 = new DateFormat2("dd/MM/yyyy");

    /**
     * yyMMddHHmm
     */
    public static final DateFormat2 Date10Format4 = new DateFormat2("yyMMddHHmm");

    /**
     * yyyyMM
     */
    public static final DateFormat2 Date6YearMonth = new DateFormat2("yyyyMM");

    /**
     * yyyy-MM
     */
    public static final DateFormat2 Date7YearMonth = new DateFormat2("yyyy-MM");

    /**
     * yyMM
     */
    public static final DateFormat2 Date4YearMonth = new DateFormat2("yyMM");

    /**
     * MM
     */
    public static final DateFormat2 DateMonth2 = new DateFormat2("MM");

    /**
     * yyyy
     */
    public static final DateFormat2 DateYear4 = new DateFormat2("yyyy");

    /**
     * HHmmssSSSSSS
     */
    public static final DateFormat2 Time12Format = new DateFormat2("HHmmssSSSSSS");

    /**
     * HH:mm:ss
     */
    public static final DateFormat2 Time8Format = new DateFormat2("HH:mm:ss");

    /**
     * HHmmss
     */
    public static final DateFormat2 Time6Format = new DateFormat2("HHmmss");

    /**
     * HHmmssSSS
     */
    public static final DateFormat2 Time9Format = new DateFormat2("HHmmssSSS");

    /**
     * hhmmssSSS
     */
    public static final DateFormat2 TimeSSFormat = new DateFormat2("hhmmssSSS");

    /**
     * yyyyMMddHH
     */
    public static final DateFormat2 DateAndHourFormat = new DateFormat2("yyyyMMddHH");

    /**
     * yyyyMM-dd-HH
     */
    public static final DateFormat2 DateForLogFormat = new DateFormat2("yyyyMM-dd-HH");

    /**
     * yyyyMM-dd
     */
    public static final DateFormat2 DateForLogDay = new DateFormat2("yyyyMM-dd");

    /**
     * MMddHHmm
     */
    public static final DateFormat2 DateTimeWithoutYS = new DateFormat2("MMddHHmm");

    /**
     * 0.00
     */
    public static final DecimalFormat2 DecimalAmtFormat = new DecimalFormat2("0.00");

    /**
     * 0
     */
    public static final DecimalFormat2 DecimalIntFormat = new DecimalFormat2("0");

    public static String toGMT(Date p_date) {
        SimpleDateFormat fmtGmt = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z", Locale.US);
        fmtGmt.setTimeZone(TimeZone.getTimeZone("GMT"));
        return fmtGmt.format(p_date);
    }

    /**
     * yyyy-MM-dd'T'HH:mm:ssZ
     */
    public static final String DateIsoFormatStr = "yyyy-MM-dd'T'HH:mm:ssZ";

    /**
     * 19位，yyyy-MM-dd HH:mm:ss，年4-月2-日 2时2:分2:秒2
     */
    public static final String DateTimeFormatStr19 = "yyyy-MM-dd HH:mm:ss";

    public static String strToDateFormat(String p_originFormat, String p_targetFormat, String p_Value) throws ParseException {
        SimpleDateFormat formatter = new SimpleDateFormat(p_originFormat);
        formatter.setLenient(false);
        Date newDate = formatter.parse(p_Value);
        formatter = new SimpleDateFormat(p_targetFormat);
        return formatter.format(newDate);
    }
}
